
import { ref } from 'vue'
import { defineStore } from "pinia";
import type { UserType} from '../types/user.d'
import type { MenuRequestType } from '@/apis/types/menu.d'
import { menuRequest } from '@/apis/api/menu'

export const useUserStore = defineStore("userInfo", () => {

   let userList = ref<UserType[]>([])
   let menuData = ref<MenuRequestType[]>([])

   const getUserList = () => {
      userList.value = [
         { username: "测试" }
      ];

   }

   const getMenuData =async  ()=>{
     await  menuRequest().then((res: MenuRequestType[]) => {
         console.log('res: ', res)
         menuData.value = res || []
       })
   }

   return {
      userList,
      getUserList,
      getMenuData,
      menuData,
   }

})

// export default defineStore("user", {
//    state() {
//       return {
//          userList: [] as UserType[],
//       };
//    },
//    actions: {
//       getList() {
//          // 后端获取数据
//          let resList: UserType[] = [
//             { username: "测试", }
//          ];
//          this.userList = resList;
//       },
//    },
// })
